package org.lanqiao.netctoss.controller.service;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.lanqiao.netctoss.entity.Buss;
import org.lanqiao.netctoss.entity.Tariff;
import org.lanqiao.netctoss.service.impl.BussServiceImpl;

/**
 * Servlet implementation class DetailServiceServlei
 */
public class DetailServiceServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public DetailServiceServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		System.out.println("bianhao:"+request.getParameter("bus_no"));
		int bus_no=Integer.parseInt(request.getParameter("bus_no"));
/*		List<Buss> lb = bussBuss.selBusstByno(new Buss(bus_no));
		List<Tariff> ltr = bussBuss.selTarBybno(new Buss(bus_no));*/
		List<Buss> lb = new BussServiceImpl().selectBusstByno(new Buss(bus_no));
		List<Tariff> ltr = new BussServiceImpl().selectTarBybno(new Buss(bus_no));
		HttpSession session = request.getSession();
		session.setAttribute("lb", lb);
		session.setAttribute("ltr",ltr);
		if(lb!=null){		
			request.getRequestDispatcher("../view/service/service_detail.jsp").forward(request, response);
		}		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
